// 	ID : pallab81
// 	PROG : 10817
// 	LANG : C++
// 	2011-08-22-19.52.07 Monday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ) {
    double endtime = clock() + ( seconds*CLOCKS_PER_SEC );
    while( clock() < endtime ) {
        ;
    }
}
inline int toI(string ss) {
    int d;
    sscanf(ss.c_str(),"%d",&d);
    return d;
}

string line;
int S,M,N;
int Mask;
Int cost;
vector< pair<int,int> > vt;
Int dp[ 101 ][ 1 << 17 ];

inline void INI() {
    Mask=0;
    cost=0;
    vt.clear();
}
inline void split1() {
    stringstream ss(line);
    int flag=1;
    for( string temp=""; getline(ss,temp,' '); ) {
        if( LN(temp)<1 )continue;
        if( flag ) {
            flag=0;
            cost+= toI(temp);
        } else {
            int id = toI(temp);
            if( ( Mask & (1<<id) ) ) {
                Mask|= ( 1<< (id+8));
            } else {
                Mask|= (1<<id);
            }
        }
    }
}
inline void split2() {
    stringstream ss(line);
    int flag=1;
    int _cost;
    int _mask=0;

    for(string temp=""; getline(ss,temp,' '); ) {
        if( LN(temp)<1 )continue;
        if( flag ) {
            flag=0;
            _cost = toI( temp );
        } else {
            int id = toI( temp );
            _mask|= ( 1<<id );
        }
    }
    vt.pb( mk(_cost, _mask) );
}
inline void Read() {
    fo(i,M) {
        getline(cin,line);
        split1();
    }
    fo(i,N) {
        getline(cin,line);
        split2();
    }
}
inline Int go(int id, int mask) {
    if( __builtin_popcount( mask )== (S*2) ) {
        return 0;
    }
    if( id == N ) {
        return (Int)1023456789;
    }

    Int &best = dp[ id ][ mask ];
    if( best!= -1 ) {
        return best;
    }

    Int na_niye = go(id+1, mask);
    for(int i=1; i<=S; ++i) {
        if( ( mask&(1<<i) ) && (vt[id].s&(1<<i)) ) {
            mask|=( 1<<(i+8) );
        } else if( ( vt[id].s&(1<<i) )  ) {
            mask|=( 1<<i );
        }
    }
    Int na = vt[id].f + go( id+1, mask );
    best = min(na_niye, na);

    return best;
}

inline void Proc() {
    SET( dp, -1 );
    Int var = go(0,Mask);
    printf("%lld\n",var+cost);
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt","rt",stdin);
#endif
    while( getline(cin,line) ) {
        sscanf(line.c_str(),"%d %d %d",&S,&M,&N);
        if( S==0 )break;
        INI();
        Read();
        Proc();
    }
    return 0;
}
